/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mycompany.psc.controllers;

import com.mycompany.psc.ejb.BackupManager;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;

/**
 *
 * @author A7med
 */
@Named(value = "backupController")
@RequestScoped
public class BackupController {
    
    @EJB
    BackupManager backupService;
    public void backUp(){
        try {
            backupService.manualBackup();
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Backup Successfull", "Backup done successfully."));
        } catch (Exception e) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Backup Failure", e.getLocalizedMessage()));
        }
    }
}
